package com.wxapp.common.util.check;

import com.wxapp.common.constant.base.IBaseEnum;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author lgl
 * @Description 比较工具类
 * @Datetime 2022/11/16 9:35
 * @Modified By
 */
public class CompareUtil {
    /**
     *   比较long
     */
    public static boolean oneBigLong(Long one, Long two) {
        return one.compareTo(two) > 0;
    }
    public static boolean twoBigLong(Long one, Long two) {
        return one.compareTo(two) < 0;
    }
    public static boolean equalLong(Long one, Long two) {
        return one.compareTo(two) == 0;
    }
    /**
     *   比较BigDecimal
     */
    public static boolean oneBigDecimal(BigDecimal one, BigDecimal two) {
        return one.compareTo(two) > 0;
    }
    public static boolean twoBigDecimal(BigDecimal one, BigDecimal two) {
        return one.compareTo(two) < 0;
    }
    public static boolean equalDecimal(BigDecimal one, BigDecimal two) {
        return one.compareTo(two) == 0;
    }
    /**
     *  比较日期Date
     */
    public static boolean oneBigDate(Date one, Date two) {
        return one.after(two);
    }
    public static boolean twoBigDate(Date one, Date two) {
        return one.before(two);
    }
    public static boolean equalDate(Date one, Date two) {
        return one.compareTo(two)==0;
    }

    /**
     *   比较日期LocalDateTime
     */
    public static boolean oneBigLocalDateTime(LocalDateTime one, LocalDateTime two) {
        return one.isAfter(two);
    }
    public static boolean twoBigLocalDateTime(LocalDateTime one, LocalDateTime two) {
        return one.isBefore(two);
    }
    public static boolean equalLocalDateTime(LocalDateTime one, LocalDateTime two) {
        return one.isEqual(two);
    }

    /**
     *   比较字符串
     */
    public static boolean equalEnum(Object one, Object two) {
        return one instanceof IBaseEnum<?> && two instanceof IBaseEnum<?> && one.equals(two);
    }
}
